package com.wkhyapp.lm.contract;

import com.wkhyapp.lm.base.BasePresenter;
import com.wkhyapp.lm.http.ApiCallback;
import com.wkhyapp.lm.http.net.BaseRequest;
import com.wkhyapp.lm.http.net.FeedbackRequest;
import com.wkhyapp.lm.http.net.SuperResponse;
import com.wkhyapp.lm.utils.MemberUtils;

/**
 * Created by fang on 2021/10/20.
 */

public class FeedbackPresenter extends BasePresenter<FeedbackView> {


    public FeedbackPresenter(FeedbackView feedbackView) {
        super(feedbackView);
    }

    public void submit(String shop,String content,String weixin,String phone,String img){
        FeedbackRequest request = new FeedbackRequest();
        request.setUserId(MemberUtils.getUid());
        request.setComplaintUser(shop);
        request.setContent(content);
        request.setImgs(img);
        request.setMobile(phone);
        request.setWechatAccount(weixin);
        addSubscription(apiStores.feedback(request),new ApiCallback<SuperResponse<String>>() {
            @Override
            public void onSuccess(SuperResponse<String> response) {
                mvpView.setSucc(response.getMessage());
            }
            @Override
            public void onFailure(String msg) {
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });

    }


    public void  getToken(){
        BaseRequest request = new BaseRequest();
        request.setUserId(16213);
        addSubscription(apiStores.getUploadToken(request),new ApiCallback<SuperResponse<String>>() {
            @Override
            public void onSuccess(SuperResponse<String> response) {
                mvpView.setToken(response.getItem());
            }
            @Override
            public void onFailure(String msg) {
//                mvpView.setfail("");
            }

            @Override
            public void onFinish() {
            }
        });
    }
}
